home *** CD-ROM | disk | FTP | other *** search
- // this gets loaded on the host if the @1 army is AI controlled
-
- // @1 = color to do AI for, @2 = color of enemy, @3 = value for @1Action variable
- macro ctf_ai_enemy 3
- {
- // these events setup the @1Action variable
-
- // before attacking @2 make sure @2 is in the game and is not an ally
- if @1SetCapture@2 testvar IsColorInGame @2 > 0 and IsAlly @1 @2 = 0 then
- setvar @1Action @3,
- trigger @1Capture@2,
- trigger @1StartTimeOut
-
- // these events choose new actions if my flag is captured by an enemy
-
- if @1Capture@2 testvar @1Action = @3 then
- order @1sarge1 follow @2flag1 inmode attack,
- order @1 group 1 follow @1sarge1 inmode defend,
- order @1 group 2 follow @2flag1 inmode attack,
- order @1 group 3 follow @2flag1 inmode attack
-
- // these events choose new actions if my flag is captured by an enemy
-
- if pickedup @1flag1 by @2 testvar isAlly @1 @2 = 0 and @1Action < 5 then
- setvar @1Action 4,
- trigger @1Rescue@1
-
- // these events choose new actions if I capture an enemy flag
-
- if pickedup @2flag1 by @1 then
- setvar @1Action 5,
- trigger @1TakeFlagToBase
-
- // these events choose new actions if any other flag is captured by an enemy
-
- if pickedup @2flag1 testvar @1Action < 4 then
- setvar @1Action @3,
- trigger @1Capture@2
-
- }
-
- // @1 = color to do AI for, @2 = color of flag
- macro ctf_check_holding_flag 2
- {
- if @1CheckIfHoldingFlags testvar hasitem @1sarge1 @2flag1 = 1 then
- setvar @1Action 5,
- trigger @1TakeFlagToBase
- }
-
- // @1 = color of army to do AI for, @2-@4 = other colors
- // @5 = letters to identify flagbase (e.g. "b" for blue, "gr" for grey)
- macro ctf_ai_macro 5
- {
- // maintain a variable which knows when we are on our base pad
- // this is used if we accidentally pickup our own flag and we are already on our base
- variable @1OnBase 0
-
- if padon @1base then
- setvar @1OnBase 1
-
- if padoff @1base then
- setvar @1OnBase 0
-
- // This variable holds the current action for @1
- // 0 means no action, 1 means goto @2 flag, 2 means goto @3 flag, 3 means goto @4 flag,
- // 4 means rescue @1 flag, 5 means take flag to base
- variable @1Action 0
-
- if startup1 then
- triggerdelay 1000 @1ChooseNewAction,
- triggerdelay 2000 @1RegularOrders
-
- if @1ChooseNewAction then
- setvar @1Action 0,
- trigger @1CheckIfHoldingFlags,
- trigger @1ChooseAction
-
- // if it's time to choose a new action but we are currently holding a flag then we should
- // always choose to take it to a base
-
- expand ctf_check_holding_flag ( @1 @1 )
- expand ctf_check_holding_flag ( @1 @2 )
- expand ctf_check_holding_flag ( @1 @3 )
- expand ctf_check_holding_flag ( @1 @4 )
-
- // if @1 has no current action then pick a random action
- // keep doing this until an action is set
- if @1ChooseAction testvar @1Action = 0 then
- trigger @1PickRandomAction,
- triggerdelay 1000 @1ChooseAction
-
- if @1PickRandomAction then random
- trigger @1SetCapture@2,
- trigger @1SetCapture@3,
- trigger @1SetCapture@4
-
- expand ctf_ai_enemy ( @1 @2 1 )
- expand ctf_ai_enemy ( @1 @3 2 )
- expand ctf_ai_enemy ( @1 @4 3 )
-
- // this event is for rescuing our own flag
- if @1Rescue@1 testvar @1Action = 4 then
- order @1sarge1 follow @1flag1 inmode attack,
- order @1 group 1 follow @1sarge1 inmode defend,
- order @1 group 2 follow @1flag1 inmode attack,
- order @1 group 3 follow @1flag1 inmode attack
-
- // this event is for taking an enemy flag to my base
- if @1TakeFlagToBase testvar @1Action = 5 then
- order @1sarge1 goto @1base inmode attack,
- order @1 group 1 follow @1sarge1 inmode defend,
- order @1 group 2 goto near@1base inmode attack,
- order @1 group 3 goto near@1base inmode attack
-
- // these events choose new actions if I rescue my own flag
-
- if pickedup @1flag1 by @1 testvar @1OnBase = 0 then
- setvar @1Action 5,
- trigger @1TakeFlagToBase
-
- if pickedup @1flag1 by @1 testvar @1OnBase = 1 then
- triggerdelay 100 @1Drop@1Flag
-
- if @1Drop@1Flag then
- dropitem @1sarge1 @1flag1 @5flagbase
-
- // these events chose a new action if we get an enemy flag to home base
-
- if padon @1base then
- triggerdelay 1000 @1ChooseNewAction
-
- // if we get our own flag back to base then drop that too
-
- if padon @1base testvar hasitem @1sarge1 @1flag1 = 1 then
- dropitem @1sarge1 @1flag1 @5flagbase
-
- // these events choose new actions if a sarge is killed
-
- if killed @1sarge1 then
- triggerdelay 5000 @1ChooseNewAction
-
- // these are the standing order regardless of what mode sarge is in
-
- if @1RegularOrders then
- setaimode @1 group 4 defend,
- setaimode @1 group 5 defend,
- order @1 group 7 goto near@1base inmode defend,
- triggerdelay 5000 @1RegularOrders
-
- // timeout code - if mode has not changed for a while then change it
-
- variable @1TimeOutVar 0
- variable @1LastTimeOutVar 1
-
- if @1StartTimeOut then
- addvar @1TimeOutVar 1,
- triggerdelay 120000 @1CheckTimeOut
-
- if @1CheckTimeOut testvar @1TimeOutVar = @1LastTimeOutVar then
- trigger @1ChooseNewAction
-
- if @1CheckTimeOut testvar @1TimeOutVar <> @1LastTimeOutVar then
- addvar @1LastTimeOutVar 1
- }
-
-